-
Notifications
You must be signed in to change notification settings - Fork 215
fix(cli): add session path tracking to prevent crashes during parallel tasks #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(cli): add session path tracking to prevent crashes during parallel tasks #119
Conversation
Manual Test ResultsTested the session path tracking fix with parallel Task subagents. Test Scenario
Results
Verification
The fix successfully prevents crashes when Task subagents operate in different working directories. |
When Task subagents create sessions in different directories (e.g., worktrees),
the session validation now uses the path where the session was created rather
than the current working directory. This fixes "Process exited unexpectedly"
errors when mobile users send messages during parallel prompt execution.
Also fixes error logging - Error objects were being logged as `{}` because
JSON.stringify doesn't capture non-enumerable Error properties.
Changes:
- Add SessionInfo interface with id and path fields
- Update Session class to track session creation path
- Modify claudeCheckSession to accept optional sessionPath
- Extract cwd from SDKSystemMessage for session tracking
- Logger now properly serializes Error objects with name/message/stack
- Added getLaunchErrorInfo helper for structured error logging
🤖 Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
6e7942a to
45e32f1
Compare
Update: Added error serialization fixThis PR now also includes a fix for error logging. Previously, Error objects were logged as Additional changes in this update:
This fixes the issue where |
When Claude Code crashes (e.g., from MaxFileReadTokenExceededError), Happy now: - Tracks consecutive crashes and limits to 3 retries - Shows informative messages: "Claude process crashed, restarting... (attempt 1/3)" - Stops gracefully after max retries instead of infinite loop - Resets crash counter on successful completion This improves UX when Claude hits edge cases like reading files that exceed the 25K token limit, which can crash the process instead of being handled gracefully. 🤖 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
Update: Added crash recovery with retry limitThis PR now includes automatic crash recovery when Claude Code crashes unexpectedly. New behavior:Before:
After:
Use case:When Claude hits edge cases like Files changed:
|
When Claude crashes and recovers, automatically resend the last message that was being processed. This prevents users from having to manually resend their message after a crash. - Track lastSentMessage for crash recovery resend - Clear immediately after resend (one-time only, prevents loops) - Show "Your message will be resent." in recovery notification - Reset lastSentMessage on successful completion Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
New commit: Auto-resend message on crash recoveryAdded How it works:
Verified in production - logs show it working: This completes the crash recovery feature - users no longer need to manually resend their message after a crash. |
Summary
Problem
When running parallel Task subagents (e.g., via worktrees):
Solution
Track the path where each session was created and use that path for validation:
SessionInfointerface withidandpathfieldssessionIdgetter maintains backward compatibilityclaudeCheckSession()now accepts optionalsessionPathparametercwdfromSDKSystemMessageduring session discoveryTest plan
yarn buildpassesyarn testpasses (102 tests)Generated with Claude Code via Happy
Co-Authored-By: Claude [email protected]
Co-Authored-By: Codex [email protected]